<?php 
session_start();
	if (isset($_SESSION['nombre'])){
require_once('Connections/tecno.php'); 
require_once('scripts/fechaMysqlNormal.php');
$id = "-1";
if (isset($_REQUEST['id'])) {
  $id = $_REQUEST['id'];
}
mysql_select_db($database_tecno, $tecno);
$query_prod = "SELECT * FROM datospersonales WHERE id = $id";
$prod = mysql_query($query_prod, $tecno) or die(mysql_error());
$row_prod = mysql_fetch_assoc($prod);
$totalRows_prod = mysql_num_rows($prod);
?>
<link href="css/demo_jconfirmaction.css" rel="stylesheet" type="text/css" />
<link href="css/styles.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<link type="text/css" href="js/themes/base/ui.all.css" rel="stylesheet" />
<script type="text/javascript" src="js/ui/ui.core.js"></script>
	<script type="text/javascript" src="js/jconfirmaction.jquery.js"></script>
	<script type="text/javascript" src="js/ui/ui.tabs.js"></script>
	<link type="text/css" href="../demos.css" rel="stylesheet" />
<script type="text/javascript">
$(document).ready(function(){
$("#tabs").tabs();
$('.ask').jConfirmAction();
});
</script>
<script type="text/javascript">
$(document).ready(function(){
//Para Guardar un contrato
//Para Guardar un pago a Capital
$(".cheked").click(function(){
	$("#guardar").css("visibility", "visible");
});
$("#guardar").click(function(){
		$("#cargando").css("display","inline");
		$.post('reportes/contrato2.php', $("#frm_contrato").serialize(),function(data){
			$('#mensaje').html(data);		
			$("#cargando").css("display", "none");
			$("#guardar").css("display", "none");
		})
	});
$("#tabs").tabs();

$('.ask').jConfirmAction();

});
</script>
<div id="right" style="float:none;margin:0px;height:440px;width:750px;">
    <!--inicio div content-right -->
    <div id="content-right">
      <h2 style="text-align:center">Contratos</h2>
      <div class="form">
       	<h3 style="text-align:center;"><span style=" font-size:15px; font-weight:bold;">Cliente:</span>
        	  <?php echo $row_prod['cedula']." - ".$row_prod['primerApellido'].", ".$row_prod['nombres'];;?> &nbsp;&nbsp;
          <span style=" font-size:15px; font-weight:bold;">Credito Disponible:</span> &nbsp;<?php echo $row_prod['credito'];?> Bs.</h3>
   <div class="demo">

<div id="tabs">
	<ul>
		<li><a href="#tabs-1">Hist&oacute;rico de Contratos</a></li>
		<li><a href="#tabs-2">Contratos por Crear</a></li>
	</ul>
<div id="tabs-1" style="height:240px">
    <?php include('sql_contratos.php'); if($totalRows_detalles>0){ ?>
<p><span style="text-align:center;" class="ui-widget-header">Por favor, haga clic en Nro. de contrato para ver o imprimir.</span></p>
<div id="detalle">
<table cellspacing="3" width="449">
<tr>
		<td class='tituloTabla'>N</td>
		<td class='tituloTabla'>Nro. Contrato</td>
		<td width="157" class='tituloTabla'>Art&iacute;culo</td>
		<td width="116" class='tituloTabla'>Monto</td>
   		<td width="1" class='tituloTabla'>&nbsp;</td>
</tr>
           <form id="frm_contrato1" name="frm_contrato1" method="post" action="">
   <?php $n =1; do {  ?>
<tr class="rowTabla">
        <td width="20"><?php echo $n;?>. </td>
        <td width="129"><a href="reportes/contrato.php?id=<?php echo $row_detalles['idContrato'];?>" target="_blank"><?php echo $row_detalles['idContrato'];?></a></td>
        <td><?php echo $row_detalles['productoDes']; ?></td>
        <td align="right" style="padding-right:15px;"><?php echo $row_detalles['monto']; ?></td>
        <td>&nbsp;</td>
</tr>
    <?php $n = $n+1; } while ($row_detalles = mysql_fetch_assoc($detalles)); ?>
<tr class="rowTabla">
  <td colspan="5" align="center">&nbsp;</td>
  </tr>
 </form></table>
</div>
<?php }else{ ?>
<p><span style="text-align:center;" class="ui-widget-header">El cliente no posee contratos</span></p>
<?php }?>
</div>
<div id="tabs-2" style="height:240px">
    <div>
<?php  include('sql_contrato.php'); if ($totalRows_detallesc>0){ ?>
<p><span style="text-align:center;" class="ui-widget-header">Por favor, seleccione los Items que desea agregar al contrato.</span></p>
<div id="detalle">
<table cellspacing="3" width="509">
<tr>
		<td class='tituloTabla'>N</td>
		<td class='tituloTabla'>Fecha de Inicio</td>
		<td width="213" class='tituloTabla'>Art&iacute;culo</td>
		<td width="123" class='tituloTabla'>Monto</td>
   		<td width="20" class='tituloTabla'>&nbsp;</td>
</tr>
           <form id="frm_contrato" name="frm_contrato"><!--reportes/contrato2.php -->
   <?php $n =1; do {  ?>
<tr class="rowTabla">
        <td width="20"><?php echo $n;?>. </td>
        <td width="107"><?php echo cambiaf_a_normal($row_detallesc['fechaV']);?></td>
        <td><?php echo $row_detallesc['productoDes']; ?></td>
        <td align="right" style="padding-right:15px;"><?php echo $row_detallesc['monto']; ?><input id="id" name="id" type="hidden" value="<?php echo $row_detallesc['id']; ?>" /></td>
        <td><input name="idArt[]" type="checkbox" id="idArt[]" class="cheked" value="<?php echo $row_detallesc['idArt']; ?>" /></td>
</tr>
    <?php $n = $n+1; } while ($row_detallesc = mysql_fetch_assoc($detallesc)); ?>
<tr class="rowTabla">
  <td colspan="5" align="center">&nbsp; 
          <a href="#"><div name="guardar" id="guardar" class="botonGrande" style="float:left; visibility:hidden;">Crear Contrato</div>
          </a><!--<input id="guardar" name="guardar" type="button" value="Guardar Contrato" class="botonGrande" width="50px" />--></td>
  </tr>
 </form></table>
</div></div>
<div id="mensaje"></div>
<?php }else{ ?>
<p><span style="text-align:center;" class="ui-widget-header">No hay items pendientes para crear contratos</span></p>
<?php }?>
</div>

</div>

</div><!-- End demo -->                   
</div>
      <div class="ui-widget"></div>
<!--fin div content-right -->
</div>
</div>
<?php }else{
		include('error.php');
	}
?>